/**
 * Project of Vehicle Routing Problem with Time Windows implements 
 * some of well-known algorithms for solving VRPTW and presents new 
 * one.
 *
 * @author Michal Drobny  
 */
package logic.car;

import java.util.List;

/**
 * Represents a simple vehicle provider for solving Vehicle Routing Problem. For
 * every nextVehicle call it provides a vehicle at the next position in the list
 * of vehicles.
 * 
 * @author Michal Drobny
 * @date 25.11.2014
 */
public class SimpleVehicleProvider extends VehicleProvider {

	/**
	 * Constructor.
	 */
	public SimpleVehicleProvider() {
		super();
	}
	
	/**
	 * Constructor.
	 * 
	 * @param vehicles The vehicles
	 */
	public SimpleVehicleProvider(List<Vehicle> vehicles) {
		super(vehicles);
	}
	
	@Override
	public boolean nextVehicle(boolean skipToNext) {
		int newIndex = vehicleIndex + 1;
		if (vehicles.size() > newIndex) {
			if (skipToNext)
				vehicleIndex = newIndex;
			return true;
		}
		return false;
	}

	@Override
	public void reset() {
		vehicleIndex = 0;
	}
}